package org.piaohao.controller;

import com.jfinal.core.Controller;
import java.util.List;
import org.piaohao.model.OrgTree;

/**
 * Created on : 2013-5-5, 12:15:56
 *
 * @author piaohao
 */
public class OrgTreeController extends Controller {

    public static final String moduleName = "机构树模块";
    public void getTree() {
        try {
            String id = getPara("id");
            List<OrgTree> ots;
            if (id.equals("root")) {
                ots = OrgTree.dao.find("select * from t_org_tree where p_id is null");
            } else {
                ots = OrgTree.dao.find("select * from t_org_tree where p_id =?", id);
            }
            renderJson(ots);
        } catch (Exception e) {
            e.printStackTrace();
            renderNull();
        }
    }
}
